<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <#assign base=request.contextPath  />
        	<base id="basePath" href="${base}">
        	<link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
        	<link rel="stylesheet" href="${base}/css/zTreeStyle.css" type="text/css">
        	<script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
        	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.core.js"></script>
        	<script type="text/javascript" src="${base}/js/zhang.js"></script>
        	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.excheck.js"></script>
        	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.exedit.js"></script>
        <link rel="stylesheet" href="${base}/js/layui/css/layui.css">
        <script src="${base}/js/layui/layui.js" type="text/javascript" charset="utf-8"></script>
     <style type="text/css">
		form{
		  padding:20px;
		}
        .layui-btn-radius{
            border-radius: 5px;
        }
		</style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <legend>日报</legend>
</fieldset>
<div class="layui-tab" lay-filter="test">
  <ul class="layui-tab-title">
    <#--<li class="layui-this" lay-id="11">写日报</li>-->
    <li>看日报</li>
   <script>
       window.onload=aaa(null,null,null);

   function aaa(sendName,logContent,test6){
          $.ajax({
              type:"POST",
                      url:"${base}/day/selectList",
                      data:{"sendName":sendName,"logContent":logContent,"test6":test6},
                      success:function(data){
                          //alert(data)
                               var htm="";
                              if(data.length>0){

                                          for(var i=0;i<data.length;i++){
                                              if(data[i].hang==null||data[i].hang==""||data[i].hang=="null"){
                                                  data[i].hang="";
                                              }
                                              if(data[i].toDay==null||data[i].toDay==""||data[i].toDay=="null"){
                                                  data[i].toDay="";
                                              }
                                              if(data[i].coordinate==null||data[i].coordinate==""||data[i].coordinate=="null"){
                                                  data[i].coordinate="";
                                              }
                                              if(data[i].remarks==null||data[i].remarks==""||data[i].remarks=="null"){
                                                  data[i].remarks="";
                                              }


                                               if (data[i].name != '' && data[i].name!=null) {
                                                    htm +=
                                                    '<div class="layui-col-xs12 layui-col-sm6 layui-col-md4"style="width: 80%;padding: 20px;">'+
                                                    '<div class="layui-collapse" >'+
                                                    '<div class="layui-colla-item">'+
                                                    '<h2 class="layui-colla-title">姓名:'+data[i].name+'<i class="layui-icon layui-icon-delete"  href="javascript:void(0)"  onclick="onDelete(' + "'" + data[i].id + "'"+')"  style="font-size:30px;float:right;" ></i></h2>'+
                                                    '<div class="layui-colla-content layui-show">'+
                                                    '<ul class="layui-timeline max-auto">'+
                                                    '<li class="layui-timeline-item">'+
                                                    '<i class="layui-icon layui-timeline-axis">&#xe63f;</i>'+
                                                    '<div class="layui-timeline-content layui-text">'+
                                                    '<h3 class="layui-timeline-title"><span>'+DateFormat(data[i].createTime)+'</span></h3>'+
                                                    '<ul>'+
                                                    '<li>今日完成工作:'+data[i].toDay+'</li>'+
                                                    '<li>未完成工作:'+data[i].hang+'</li>'+
                                                    '<li>需协调工作:'+data[i].coordinate+'</li>'+
                                                    '<li>备注:'+data[i].remarks+'</li>'+
                                                    '</ul>'+
                                                    '</div>'+
                                                    '</li>'+
                                                    '</ul>'+
                                                    '</div>'+
                                                    '</div>'+
                                                    '</div>'+
                                                    '</div>'
                                                  }

                                      }



                          }else {
                               htm="";
                           }
                          $("#day").html(htm)

                      }
          });
   }


   </script>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
    	<form class="layui-form layui-form-pane" action="">
			    <div class="layui-form-item">
			    	<div class="layui-inline">
			            <label class="layui-form-label">发送人</label>
					        <div class="layui-input-inline">
					            <input type="text" name="username"  id="sendName" placeholder="请输入" autocomplete="off" class="layui-input">
					        </div>
			        </div>
					    <div class="layui-inline">
						      <label class="layui-form-label">日期范围</label>
						      <div class="layui-input-inline">
						        <input type="text" class="layui-input" id="test6" placeholder=" 至 ">
						      </div>
						</div>
			        <div class="layui-inline">
			            <label class="layui-form-label">日志内容</label>
					        <div class="layui-input-inline">
                            <input type="text" name="username" id="logContent" placeholder="请输入" autocomplete="off" class="layui-input">					        </div>
			        </div>
			    <div class="layui-inline">
			         <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="submin()" style="background-color: #0092EF;">开始搜索</button>
					 <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
			    </div>
			    </div>
			</form>

			<div id="day">



             </div>
    	</div>
    </div>
</div>
<script>
 layui.use(['element', 'form', 'table', 'layer',  'laydate'], function () {
        		var form = layui.form;
                var table = layui.table;
                var layer = layui.layer;
                var laydate = layui.laydate;
                var element = layui.element;
                var layedit = layui.layedit;
                var  $ = layui.jquery;

              laydate.render({
                elem: '#test6'
                ,range: true
              });

  var active = {
   tabChange: function(){
      //切换到指定Tab项
      element.tabChange('demo', '22'); //切换到：用户管理
    }
  };

  $('.site-demo-active').on('click', function(){
    var othis = $(this), type = othis.data('type');
    active[type] ? active[type].call(this, othis) : '';
  });
  var layid = location.hash.replace(/^#test=/, '');
  element.tabChange('test', layid);

  element.on('tab(test)', function(elem){
    location.hash = 'test='+ $(this).attr('lay-id');
  });

});


//提交
  function onSubmit(){
  if(!isNull()){
  return;
  }
   var jsonData = {};
    //姓名
    jsonData.name = $("#name").val();
    //今日完成工作
    jsonData.toDay = $("#toDay").val();
    //未完成工作
    jsonData.hang = $("#hang").val();
    //需协调工作
    jsonData.coordinate = $("#coordinate").val();
    //备注
    jsonData.remarks = $("#remarks").val();



    $.ajax({
        type:"POST",
        url:"${base}/day/insertDay",
        data:{"param":JSON.stringify(jsonData)},
        success:function(data){






layer.msg("添加成功");

          setTimeout(function(){
             var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
          },800)


          //姓名
             jsonData.name = $("#name").val("");
              //今日完成工作
              jsonData.toDay = $("#toDay").val("");
              //未完成工作
              jsonData.hang = $("#hang").val("");
              //需协调工作
              jsonData.coordinate = $("#coordinate").val("");
              //备注
              jsonData.remarks = $("#remarks").val("");

                 var table = layui.table;
                     //表刷新方法
                     table.reload('testReload', {
                      url: '${base}/day/selectDay'
                      ,where: {} //设定异步数据接口的额外参数
                       //,height: 300
                  });
          }
    });



  }


//删除
function onDelete(id){

//提示是否删除这条数据
//data里边的customerId是需要和实体类里边的id是一样的,不然是传不过来参数的
layer.confirm('真的要删除吗?',function(index){
    $.ajax({
        type:"POST",
        url:"${base}/day/deleteDay",
        data:{"id":id},
        sync:false,
        success:function(data){

              aaa(null,null,null);
            //关闭删除是否删除的提示框
              layer.close(index);
        }
    });
    });
}





function submin(){
aaa($("#sendName").val(),$("#logContent").val(),$("#test6").val());
}








</script>
</body>
</html>